<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js" type="text/javascript"> </script>
<script src="jquery.countdown.min.js" type="text/javascript"> </script>
<style type="text/css"> @import "jquery.countdown.css"; </style>
</head>
<body>
<script type="text/javascript">
	function CloseAppointment(){
		
	}
	$(function(){
		var expected = new Date();
		expected.setMinutes(expected.getMinutes() + 15);
		$('#countDown').countdown({
			until: expected,
			format: 'MS',
			compact: true
		
		});
	});

 </script>
<?php
	$appointmentId = $_POST['appointment_id'];
	$db = new PDO("sqlite:siwoz.db");
	$result = $db->query("SELECT name FROM appointments a JOIN Patients p on a.patient_id = p.id where a.id = '$appointmentId' ");
	$db->query("UPDATE appointments SET state = 1 where id = '$appointmentId' ");
	$appointment = $result->fetch();
?>
<div>
		<p>
			Pacjent: <?php echo "{$appointment['name']}" ?>
		</p>
		<p>
		Czas pozostały do końca wizyty:
		<span id='countDown' class='countdown'> </span>
		</p>
	</div>
	<div> 
	<form method='POST' action='closeAppointment.php'>
	<input type='hidden' id='appointment_id' name='appointment_id' value='<?php echo $appointmentId ?>' />
	
	<input type="submit" value='Zakończ' />
	</form>
	</div>

</body> </html>